# 1-beta function for describing hybrid fitness
  #maxcost is fitness loss for F1s
  # x is the hybrid index value (between 0-1)
  # alpha and beta are the paramters of the beta distribution
bfunc<-function(maxcost, x, alpha, beta){
  1-maxcost*dbeta(x, alpha, beta)/dbeta(alpha/(alpha+beta), alpha, beta)
}


# function to convert difference in hybrid index into a probability
# function varies with choosiness
  # diffs is difference in HI
  # C is choosiness (0<C<1)
  # a and k are parameters
choosiness<-function(diffs, C, a=5, k=100){
  exp(a-C*k*diffs)/(1+exp(a-C*k*diffs))  
}